
#include "GrassyLand.h"

GrassyLand::GrassyLand(){

	running = false;
	displaySurface = NULL;
}

int GrassyLand::execute(){

	if(!init())
		return -1;

	SDL_Event e;
	
	running = true;

#ifdef  FRAME_LIMIT
	Uint32 frameLimiter = SDL_GetTicks();
	int frameCounter = 0;
#endif

	while(running)
	{

		while(SDL_PollEvent(&e))
			Event::OnEvent(&e);

		loop();
		render();

	#ifdef  FRAME_LIMIT
		if(frameCounter >= FRAME_LIMIT)
		{
			frameCounter = 0;

			if(SDL_GetTicks() < frameLimiter + 1000)
				SDL_Delay(frameLimiter + 1000 - SDL_GetTicks());
				
			frameLimiter = SDL_GetTicks();
		}
		else
			frameCounter++;
	#endif
		
	}

	cleanup();
	
	return 0;
}

